home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 27 / CU Amiga Magazine's Super CD-ROM 27 (1998)(EMAP Images)(GB)[!][issue 1998-10].iso / CUCD / Programming / JForth / JTools / JARP / arp.j next >
Encoding:
Text File  |  1992-01-26  |  25.8 KB  |  681 lines

  1. \ AMIGA JForth Include file.
  2. \
  3.  
  4.  
  5. include? :struct ju:c_struct
  6. anew task-arp_j
  7.  
  8. EXISTS? LIBRARIES_ARPBASE_H NOT .IF 
  9. : LIBRARIES_ARPBASE_H ;
  10.  
  11. ( *********************************************************************)
  12. (  *)
  13. (  *    AmigaDOS Replacement Project [ARP] -- Library Include File 'C')
  14. (  *)
  15. (  **********************************************************************)
  16. (  *)
  17. (  *    History:)
  18. (  *)
  19. (  *    Version:    arpbase.h,v 34.00 02/27/88)
  20. (  *)
  21. (  *    Created by:    SDB)
  22. (  *    Revised:    SDB -- Just bag earlier versions, since didn't have)
  23. (  *                   time to maintain C header during 'the last days'.)
  24. (  *                   Created this file mainly from arpbase.i.)
  25. (  *)
  26. (  *    Revised:    SDB -- Added stuff for version 32, ASyncRun[])
  27. (  *                   returns and data structures.)
  28. (  *            SDB -- Added ERROR_NO_CLI)
  29. (  *            SDB -- Added final resident data structures,)
  30. (  *                   final ASyncRun[] data structures, and)
  31. (  *                   date. Final edits for V33.4 release.)
  32. (  **********************************************************************)
  33. (  *)
  34. (  *)
  35. (  *    Originally: Copyright [c] 1987, by Scott Ballantyne)
  36. (  *)
  37. (  *    The arp.library, and related code and files may be freely used)
  38. (  *    by supporters of ARP.  Modules in the arp.library may not be)
  39. (  *    extracted for us in independent code, but you are welcome to provide)
  40. (  *    the arp.library with your work and call on it freely.)
  41. (  *)
  42. (  *    You are equally welcome to contribute new functions, improve the)
  43. (  *    ones within, or suggest additions.)
  44. (  *)
  45. (  *    BCPL programs are not welcome to call on the arp.library.)
  46. (  *    The welcome mat is out to all others.)
  47. (  *)
  48. (  ********************************************************************)
  49.  
  50. \  .THEN   \ %? Forced .THEN to prevent nesting!!!
  51. \  EXISTS? EXEC_TYPES_H NOT .IF 
  52. include? EXEC_TYPES_H ji:exec/types.j 
  53. \  .THEN  
  54.  
  55. \ EXISTS? EXEC_LIBRARIES_H NOT .IF 
  56. include? EXEC_LIBRARIES_H ji:exec/libraries.j 
  57. \ .THEN  
  58.  
  59. \ EXISTS? EXEC_LISTS_H NOT .IF 
  60. include? EXEC_LISTS_H ji:exec/lists.j 
  61. \ .THEN  
  62.  
  63. \ EXISTS? EXEC_SEMAPHORES_H NOT .IF 
  64. include? EXEC_SEMAPHORES_H ji:exec/semaphores.j 
  65. \ .THEN  
  66.  
  67. \ EXISTS? LIBRARIES_DOS_H NOT .IF 
  68. include? LIBRARIES_DOS_H ji:libraries/dos.j 
  69. \ .THEN  
  70.  
  71. (  arp.library's node structure, not too hefty even now. )
  72.  
  73. :STRUCT ArpBase
  74.     STRUCT Library    LibNode    (  Standard library node    )
  75.     LONG SegList    (  Pointer to loaded libcode    )
  76.     BYTE Flags        (  Not used, yet!        )
  77.     BYTE ESCChar    (  Character used for escaping    )
  78.     LONG ArpReserved1    (  ArpLib's use only!        )
  79.     APTR EnvBase    (  Dummy library for MANX compatibility )
  80.     APTR DosBase    (  Dos library pointer        )
  81.     APTR GfxBase    (  Graphics lib pointer        )
  82.     APTR IntuiBase    (  Intuition lib pointer    )
  83.     STRUCT MinList    ResLists    (  Resource trackers        )
  84.     APTR ResidentPrgList (  Installed programs )
  85.     STRUCT SignalSemaphore ResPrgProtection (  Protection for above )
  86. ;STRUCT 
  87.  
  88. (  Following is here *only* for information and for compatibility)
  89. (  * with MANX, don't use in new code!)
  90. (  )
  91.  
  92. :STRUCT EnvBase
  93.     STRUCT Library    LibNode    (  Standard library node for linkage )
  94.     APTR EnvSpace    (  Access only when Forbidden! )
  95.     LONG EnvSize    (  Total allocated mem for EnvSpace )
  96.     APTR ArpBase    (  Added in V32 for Resource Tracking )
  97. ;STRUCT 
  98.  
  99. (  These are used in release 33.4, but not by the library code. Instead,)
  100. (  * individual programs check for these flags. Not ideal, but such is life.)
  101. (  *)
  102. (  )
  103.  
  104. 0 CONSTANT ARPB_WILD_WORLD
  105. 1 CONSTANT ARPB_WILD_BCPL
  106.  
  107. 1 0 << constant ARPF_WILD_WORLD
  108. 1 1 << constant ARPF_WILD_BCPL
  109.  
  110. ( ************** C SPECIFIC STUFF ************************************)
  111. (  There are a few things in arp.library that are only directly acessable)
  112. (  * from assembler.  The glue routines provided by us for all 'C' compilers)
  113. (  * use the following conventions to make these available to C programs.)
  114. (  * The glue for other language's should use as similar a mechanism as)
  115. (  * possible, so that no matter what language or compiler we speak, when)
  116. (  * talk about arp, we will know what the other guy is saying.)
  117. (  *)
  118. (  * Here are the cases:)
  119. (  *    Atol[] - if a bad digit is encountered, will store a ERRBADINT in)
  120. (  *         Errno, the return from Atol[] will be the bad character)
  121. (  *         encountered.  Note: Atol[] will not clear Errno if return)
  122. (  *         is successful.)
  123. (  *    Trackers: All tracking calls return the Tracker pointer in A1 as a)
  124. (  *          secondary result, you can obtain this from the global)
  125. (  *          variable LastTracker immediately after the call.)
  126. (  * Finally, GetTracker[] syntax is differnt for C and assembler, for 'C')
  127. (  * the Syntax is GetTraker[ ID ], the binding routine will store the ID)
  128. (  * into the tracker on return.)
  129. (  *)
  130. (  * In cases where you have allocated a tracker before you have obtained a)
  131. (  * resource [usually the most efficient method], and the resource has not)
  132. (  * been obtained, you will need to clear the tracker id.  The macro CLEAR_ID[])
  133. (  * has been provided for that purpose.  It expects a pointer to a DefaultTracker)
  134. (  * sort of struct.)
  135. (  *)
  136. (  )
  137.  
  138. \ %? extern LONG Errno;    /* Error returns not reportable by functions */ 
  139. \ %? extern struct DefaultTracker *LastTracker;    /* Look here after a tracking call */ 
  140. 1  constant ERRBADINT (  Atol[] could not convert string to number )
  141.  
  142. \ %? #define CLEAR_ID( t )    ((SHORT *) t)[-1] = NULL: CLEAR_ID ;
  143.  
  144. ( )
  145. (  * Non controversial, normal library style stuff)
  146. (  )
  147.  
  148. \ %? #define ArpName        "arp.library"        /* Name to use when opening */
  149. 34  constant ArpVersion (  Current version of arplib )
  150.  
  151.  
  152. ( )
  153. (  * The alert object is what you use if you really must return an )
  154. (  * alert to the user. You would normally OR this with another alert number)
  155. (  * from the alerts.h file, generally, these should be NON deadend alerts.)
  156. (  *)
  157. (  * For example, if you can't open ArpLibrary:)
  158. (  *    Alert[ [AG_OpenLib|AO_ArpLib], 0L];)
  159. (  *)
  160. (  )
  161. $ 00008036  constant AO_ArpLib (  Alert object )
  162.  
  163. ( )
  164. (  * Alerts that arp.library can return.)
  165. (  )
  166.  
  167. $ 03600000  constant AN_ArpLib (  Alert number            )
  168. $ 03610000  constant AN_ArpNoMem (  No more memory        )
  169. $ 03610002  constant AN_ArpInputMem (  No memory for input buffer    )
  170. $ 83610003  constant AN_ArpNoMakeEnv (  No memory to make EnvLib    )
  171.  
  172. $ 83630001  constant AN_ArpNoDOS (  Can't open DOS        )
  173. $ 83630002  constant AN_ArpNoGfx (  Can't open graphics.library    )
  174. $ 83630003  constant AN_ArpNoIntuit (  Can't open intuition        )
  175. $ 83640000  constant AN_BadPackBlues (  Bad packet returned to SendPacket[]    )
  176. $ 83600003  constant AN_Zombie (  Zombie roaming around system )
  177.  
  178. $ 83600002  constant AN_ArpScattered (  Scatter loading not allowed for arp )
  179.  
  180. (  Return codes you can get from calling arp.library's Assign[] function )
  181.  
  182. 0  constant ASSIGN_OK (  Everything is cool and groovey )
  183. 1  constant ASSIGN_NODEV (  "Physical" is not valid for assignment )
  184. 2  constant ASSIGN_FATAL (  Something really icky happened )
  185. 3  constant ASSIGN_CANCEL (  Tried to cancel something but it won't cancel )
  186.  
  187. (  Size of buffer you need if you are going to call ReadLine[] )
  188.  
  189. 256  constant MaxInputBuf
  190.  
  191. ( ************************* File Requester ***************************)
  192. ( **************** Submit the following to FileRequest[] *************)
  193. ( ********************************************************************)
  194.  
  195. :STRUCT FileRequester
  196.     APTR  fr_Hail        (  Hailing text            )
  197.     APTR  fr_File        (  Filename array [FCHARS * N]    )
  198.     APTR  fr_Dir        (  Directory array [DSIZE + 1]    )
  199.     APTR  fr_Window    (  Window requesting files or NULL)
  200.     BYTE  fr_FuncFlags        (  Set bitdef's below        )
  201.     BYTE  fr_reserved1        (  Set to NULL            )
  202. \ %?     VOID    (*fr_Function)();    /* Your function, see bitdef's    */    
  203.     LONG  fr_Function        (  RESERVED            )
  204.     LONG  fr_reserved2        (  RESERVED            )
  205. ;STRUCT 
  206.  
  207. (  The following are the defines for fr_FuncFlags.  These bits tell)
  208. (  * FileRequest[] what your fr_UserFunc is expecting, and what FileRequest[])
  209. (  * should call it for.)
  210. (  *)
  211. (  * You are called like so:)
  212. (  * fr_Function[Mask, Object])
  213. (  * ULONG    Mask;)
  214. (  * CPTR        *Object;)
  215. (  *)
  216. (  * The Mask is a copy of the flag value that caused FileRequest[] to call)
  217. (  * your function. You can use this to determine what action you need to)
  218. (  * perform, and exactly what Object is, so you know what to do and)
  219. (  * what to return.)
  220. (  )
  221.  
  222. 7  constant FRB_DoWildFunc (  Call me with a FIB and a name, ZERO return accepts. )
  223. 6  constant FRB_DoMsgFunc (  You get all IDCMP messages not for FileRequest[] )
  224. 5  constant FRB_DoColor (  Set this bit for that new and different look )
  225. 4  constant FRB_NewIDCMP (  Force a new IDCMP [only if fr_Window != NULL] )
  226. 3  constant FRB_NewWindFunc (  You get to modify the newwindow structure. )
  227. 2  constant FRB_AddGadFunc (  You get to add gadgets. )
  228. 1  constant FRB_GEventFunc (  Function to call if one of your gadgets is selected. )
  229. 0  constant FRB_ListFunc (  Not implemented yet. )
  230.  
  231. 1 7 << constant FRF_DoWildFunc
  232. 1 6 << constant FRF_DoMsgFunc
  233. 1 5 << constant FRF_DoColor
  234. 1 4 << constant FRF_NewIDCMP
  235. 1 3 << constant FRF_NewWindFunc
  236. 1 2 << constant FRF_AddGadFunc
  237. 1 1 << constant FRF_GEventFunc
  238. 1 0 << constant FRF_ListFunc
  239.  
  240. 32  constant FCHARS (  Filename size )
  241. 33  constant DSIZE (  Directory name size )
  242.  
  243. $ 7680  constant FR_FIRST_GADGET (  User gadgetID's must be less than this value )
  244.  
  245. ( ***********************************************************************)
  246. ( ********************* PATTERN MATCHING ********************************)
  247. ( ***********************************************************************)
  248.  
  249. (  Structure expected by FindFirst[], FindNext[] )
  250. ( )
  251. (  * You need to allocate this structure and initialize it as follows:)
  252. (  *)
  253. (  * Set ap_BreakBits to the signal bits [CDEF] that you want to take a)
  254. (  * break on, or NULL, if you don't want to convenience the user.)
  255. (  *)
  256. (  * if you want to have the FULL PATH NAME of the files you found, allocate)
  257. (  * a buffer at the END of this structure, and put the size of it into)
  258. (  * ap_Length.  If you don't want the full path name, make sure you set)
  259. (  * ap_Length to zero.  In this case, the name of the file, and stats are)
  260. (  * available in the ap_Info, as per usual.)
  261. (  *)
  262. (  * Then call FindFirst[] and then afterwards, FindNext[] with this structure.)
  263. (  * You should check the return value each time [see below] and take the)
  264. (  * appropriate action, ultimately calling FreeAnchorChain[] when there)
  265. (  * are no more files and you are done.  You can tell when you are done by)
  266. (  * checking for the normal AmigaDOS return code ERROR_NO_MORE_ENTRIES.)
  267. (  *)
  268. (  * You will also have to check the DirEntryType variable in the ap_Info)
  269. (  * structure to determine what exactly you have received.)
  270. (  )
  271.  
  272. :STRUCT AnchorPath
  273.     APTR ap_Base    (  Pointer to first anchor )
  274.     APTR ap_Last    (  Pointer to last anchor )
  275.     LONG ap_BreakBits    (  Bits to break on )
  276.     LONG ap_FoundBreak    (  Bits we broke on. Also returns ERROR_BREAK )
  277.     LONG ap_Length    (  Actual size of ap_Buf, set to 0 if no ap_Buf )
  278.     STRUCT FileInfoBlock    ap_Info
  279.         BYTE ap_Buf
  280. ;STRUCT 
  281. ( )
  282. (  * structure used by the pattern matching functions, no need to obtain, diddle)
  283. (  * or allocate this yourself.)
  284. (  )
  285.  
  286. :STRUCT Anchor
  287.     APTR an_Next
  288.     APTR an_Pred
  289.     APTR an_Lock
  290.     APTR an_Info
  291.     LONG an_Status        (  Type of this anchor node )
  292. \ %?     union { 
  293.         SHORT an_Text    (  Actual instance of a BSTRing )
  294.         ( %?) 2 BYTES an_Actual    (  more memory allocated as required )
  295. \ %?     } an_BSTR; 
  296. ;STRUCT 
  297. (  This structure takes a pointer, and returns FALSE if wildcard was not)
  298. (  * found by FindFirst[])
  299. (  )
  300. \ %? #define IsWild( ptr )        ( *((LONG *)(ptr)) ): IsWild ;
  301.  
  302. (  Constants used by wildcard routines )
  303. (  These are the pre-parsed tokens referred to by pattern match.  It is not)
  304. (  * necessary for you to do anything about these, FindFirst[] FindNext[])
  305. (  * handle all these for you.)
  306. (  )
  307.  
  308. $ 80  constant P_ANY (  Token for '*' or '#?' )
  309. $ 81  constant P_SINGLE (  Token for '?' )
  310. $ 82  constant P_ORSTART (  Token for '[' )
  311. $ 83  constant P_ORNEXT (  Token for '|' )
  312. $ 84  constant P_OREND (  Token for ']' )
  313. $ 85  constant P_TAG (  Token for '{' )
  314. $ 86  constant P_TAGEND (  Token for '}' )
  315. $ 87  constant P_NOTCLASS (  Token for '^' )
  316. $ 88  constant P_CLASS (  Token for '[]' )
  317. $ 89  constant P_REPBEG (  Token for '[' )
  318. $ 8A  constant P_REPEND (  Token for ']' )
  319.  
  320. (  Values for an_Status, NOTE: these are the actual bit numbers. )
  321. 1  constant COMPLEX_BIT (  Parsing complex pattern )
  322. 2  constant EXAMINE_BIT (  Searching directory )
  323.  
  324. (  Returns from FindFirst[] FindNext[] )
  325. (  Note that you can also get return codes as defined in dos.h,)
  326. (  * particularly you can get ERROR_NO_MORE_ENTRIES.)
  327. (  )
  328.  
  329. 303  constant ERROR_BUFFER_OVERFLOW (  User or internal buffer overflow )
  330. 304  constant ERROR_BREAK (  A break character was received )
  331.  
  332. (  Structure used by AddDANode[], AddDADevs[], FreeDAList[].)
  333. (  *)
  334. (  * This structure is used to create lists of names, which normally)
  335. (  * are devices, assigns, volumes, files, or directories.)
  336. (  )
  337.  
  338. :STRUCT DirectoryEntry
  339.     APTR  de_Next    (  Next in list )
  340.     BYTE  de_Type            (  DLX_mumble )
  341.     BYTE  de_Flags        (  For future expansion, DO NOT USE! )
  342.         BYTE de_Name
  343. ;STRUCT 
  344.  
  345. (  Defines you use to get a list of the devices you want to look at.)
  346. (  * For example, to get a list of all directories and volumes, do:)
  347. (  *)
  348. (  *    AddDADevs[ mydalist, [DLF_DIRS | DLF_VOLUMES] ])
  349. (  *)
  350. (  * After this, you can examine the de_type field of the elements added to)
  351. (  * your list [if any] to discover specifics about the objects added.)
  352. (  *)
  353. (  * Note that if you want only devices which are also disks, you must request)
  354. (  * [DLF_DEVICES | DLF_DISKONLY].)
  355. (  )
  356.  
  357. 0  constant DLB_DEVICES (  Return devices )
  358. 1  constant DLB_DISKONLY (  Modifier for above: Return disk devices only )
  359. 2  constant DLB_VOLUMES (  Return volumes only )
  360. 3  constant DLB_DIRS (  Return assigned devices only )
  361.  
  362. 1 0 << constant DLF_DEVICES
  363. 1 1 << constant DLF_DISKONLY
  364. 1 2 << constant DLF_VOLUMES
  365. 1 3 << constant DLF_DIRS
  366.  
  367. (  Legal de_Type values, check for these after a call to AddDADevs[], or use)
  368. (  * on your own as the ID values in AddDANode[].)
  369. (  )
  370.  
  371. 0  constant DLX_FILE (  AddDADevs[] can't determine this )
  372. 8  constant DLX_DIR (  AddDADevs[] can't determine this )
  373. 16  constant DLX_DEVICE (  It's a resident device )
  374.  
  375. 24  constant DLX_VOLUME (  Device is a volume )
  376. 32  constant DLX_UNMOUNTED (  Device is not resident )
  377.  
  378. 40  constant DLX_ASSIGN (  Device is a logical assignment )
  379.  
  380. ( *******************************************************************)
  381. ( ********************* RESOURCE TRACKING ***************************)
  382. ( *******************************************************************)
  383.  
  384. (  Note: ResList MUST be a DosAllocMem'ed list!, this is done for)
  385. (  * you when you call CreateTaskResList[], typically, you won't need)
  386. (  * to access/allocate this structure.)
  387. (  )
  388.  
  389. :STRUCT ResList
  390.     STRUCT MinNode     rl_Node    (  Used by arplib to link reslist's )
  391.     APTR  rl_TaskID    (  Owner of this list )
  392.     STRUCT MinList     rl_FirstItem    (  List of TrackedResource's )
  393.     APTR  rl_Link    (  SyncRun's use - hide list here )
  394. ;STRUCT 
  395. ( )
  396. (  * The rl_FirstItem list [above] is a list of TrackedResource [below].)
  397. (  * It is very important that nothing in this list depend on the task)
  398. (  * existing at resource freeing time [i.e., RemTask[0L] type stuff,)
  399. (  * DeletePort[] and the rest].)
  400. (  *)
  401. (  * The tracking functions return a struct Tracker *Tracker to you, this)
  402. (  * is a pointer to whatever follows the tr_ID variable.)
  403. (  * The default case is reflected below, and you get it if you call)
  404. (  * GetTracker[] [ see DefaultTracker below].)
  405. (  *)
  406. (  * NOTE: The two user variables mentioned in an earlier version don't)
  407. (  * exist, and never did. Sorry about that [SDB].)
  408. (  *)
  409. (  * However, you can still use ArpAlloc[] to allocate your own tracking nodes)
  410. (  * and they can be any size or shape you like, as long as the base structure)
  411. (  * is preserved. They will be freed automagically just like the default trackers.)
  412. (  )
  413.  
  414. :STRUCT TrackedResource
  415.     STRUCT MinNode    tr_Node    (  Double linked pointer )
  416.     BYTE tr_Flags    (  Don't touch )
  417.     BYTE tr_Lock    (  Don't touch, for Get/FreeAccess[] )
  418.     SHORT tr_ID        (  Item's ID )
  419.     ( )
  420. (      * The struct DefaultTracker *Tracker portion of the structure.)
  421. (      * The stuff below this point can conceivably vary, depending)
  422. (      * on user needs, etc.  This reflects the default.)
  423. (      )
  424.     union{ 
  425.                 LONG  tr_Resource
  426.                 LONG tg_Verify    (  For use during TRAK_GENERIC )
  427.     }UNION{
  428. \ %?     } tr_Object;            /* The thing being tracked */ 
  429. \ %?     union { 
  430. \ %?         VOID    (*tg_Function)(); /* Function to call for TRAK_GENERIC */    
  431.         LONG tg_Function  ( Function to call for TRAK_GENERIC )    
  432.         APTR tr_Window2    (  For TRAK_WINDOW )
  433. \ %?     } tr_Extra;                /* Only needed sometimes */ 
  434.     }UNION
  435. ;STRUCT 
  436.  
  437. tg_Verify  constant tg_Value (  Ancient compatibility )
  438.  
  439. (  You get a pointer to a struct of the following type when you call)
  440. (  * GetTracker[].  You can change this, and use ArpAlloc[] instead of)
  441. (  * GetTracker[] to do tracking. Of course, you have to take a wee bit)
  442. (  * more responsibility if you do, as well as if you use TRAK_GENERIC)
  443. (  * stuff.)
  444. (  *)
  445. (  * TRAK_GENERIC folks need to set up a task function to be called when an)
  446. (  * item is freed.  Some care is required to set this up properly.)
  447. (  *)
  448. (  * Some special cases are indicated by the unions below, for TRAK_WINDOW,)
  449. (  * if you have more than one window opened, and don't want the IDCMP closed)
  450. (  * particularly, you need to set a ptr to the other window in dt_Window2.)
  451. (  * See CloseWindowSafely[] for more info.  If only one window, set this to NULL.)
  452. (  *)
  453. (  )
  454.  
  455. :STRUCT DefaultTracker
  456. \ %?     union { 
  457.      union{ 
  458.                LONG dt_Resource
  459.         LONG tg_Verify    (  For use during TRAK_GENERIC )
  460. \ %?     } dt_Object;            /* The object being tracked */ 
  461. \ %?     union {
  462.     }UNION{ 
  463. \ %?         VOID    (*tg_Function)();  /* Function to call for TRAK_GENERIC */    
  464.          LONG tg_Function  ( Function to call for TRAK_GENERIC )    
  465.         APTR dt_Window2    (  For TRAK_WINDOW )
  466. \ %?     } dt_Extra; 
  467.     }Union
  468. ;STRUCT 
  469.  
  470. (  Items the tracker knows what to do about )
  471.  
  472. 0  constant TRAK_AAMEM (  Default [ArpAlloc] element )
  473. 1  constant TRAK_LOCK (  File lock )
  474. 2  constant TRAK_FILE (  Opened file )
  475. 3  constant TRAK_WINDOW (  Window -- see docs )
  476. 4  constant TRAK_SCREEN (  Screen )
  477. 5  constant TRAK_LIBRARY (  Opened library )
  478. 6  constant TRAK_DAMEM (  Pointer to DosAllocMem block )
  479. 7  constant TRAK_MEMNODE (  AllocEntry[] node )
  480. 8  constant TRAK_SEGLIST (  Program segment )
  481. 9  constant TRAK_RESLIST (  ARP [nested] ResList )
  482. 10  constant TRAK_MEM (  Memory ptr/length )
  483. 11  constant TRAK_GENERIC (  Generic Element, your choice )
  484. 12  constant TRAK_DALIST (  DAlist [ aka file request ] )
  485. 13  constant TRAK_ANCHOR (  Anchor chain [pattern matching] )
  486. 13  constant TRAK_MAX (  Poof, anything higher is tossed )   
  487.  
  488. 7  constant TRB_UNLINK (  Free node bit )
  489. 6  constant TRB_RELOC (  This may be relocated [not used yet] )
  490. 5  constant TRB_MOVED (  Item moved )
  491.  
  492. 1 7 << constant TRF_UNLINK
  493. 1 6 << constant TRF_RELOC
  494. 1 5 << constant TRF_MOVED
  495.  
  496. (  Returns from CompareLock[] )
  497. 0  constant LCK_EQUAL (  The two locks refer to the same object )
  498. 1  constant LCK_VOLUME (  Locks are on the same volume )
  499. 2  constant LCK_DIFVOL1 (  Locks are on different volumes )
  500. 3  constant LCK_DIFVOL2 (  Locks are on different volumes )
  501.  
  502. ( ***************************** ASyncRun[] **************************)
  503. ( )
  504. (  * Message sent back on your request by an exiting process.)
  505. (  * You request this by putting the address of your message in pcb_LastGasp,)
  506. (  * and initializing the ReplyPort variable of your ZombieMsg to the)
  507. (  * port you wish the message posted to.)
  508. (  )
  509.  
  510. :STRUCT ZombieMsg
  511.     STRUCT Message    zm_ExecMessage
  512.     LONG zm_TaskNum        (  Task ID )
  513.     LONG zm_ReturnCode        (  Process's return code )
  514.     LONG zm_Result2        (  System return code )
  515.     STRUCT DateStamp zm_ExitTime    (  Date stamp at time of exit )
  516.     LONG zm_UserInfo        (  For whatever you wish. )
  517. ;STRUCT 
  518.  
  519. (  Structure required by ASyncRun[] -- see docs for more info. )
  520.  
  521. :STRUCT ProcessControlBlock
  522.     LONG pcb_StackSize        (  Stacksize for new process )
  523.     BYTE pcb_Pri        (  Priority of new task )
  524.     BYTE pcb_Control        (  Control bits, see defines below )
  525.     APTR pcb_TrapCode        (  Optional Trap Code )
  526.     LONG pcb_Input
  527. LONG p_Output    (  Optional stdin, stdout )
  528. \ %?     union { 
  529.         LONG pcb_SplatFile    (  File to use for Open["*"] )
  530.         APTR pcb_ConName    (  CON: filename )
  531. \ %?     } pcb_Console; 
  532.     LONG pcb_SplatFile        (  File to use for Open["*"] )
  533.         LONG pcb_LoadedCode
  534.     APTR pcb_LastGasp     (  ReplyMsg[] to be filled in by exit )
  535.     APTR pcb_WBProcess    (  Valid only when PRB_NOCLI )
  536. ;STRUCT 
  537.  
  538. (  Some programs appear to have bugs in the startup code that does not handle)
  539. (  * well a zero length command line [lattice startup has this, but is probably)
  540. (  * not unique].  Use this macro to pass a null cmd line to a process using)
  541. (  * either ASyncRun[] or SyncRun[])
  542. (  )
  543.  
  544. \ %? #define NOCMD    "\n"
  545.  
  546. (  The following control bits determine what ASyncRun[] does on Abnormal Exits)
  547. (  * and on background process termination. )
  548. (  )
  549.  
  550. 0  constant PRB_SAVEIO (  Don't free/check file handles on exit )
  551. 1  constant PRB_CLOSESPLAT (  Close Splat file, must request explicitly )
  552. 2  constant PRB_NOCLI (  Don't create a CLI process )
  553. 3  constant PRB_INTERACTIVE (  This should be interactive )
  554. 4  constant PRB_CODE (  Dangerous yet enticing )
  555. 5  constant PRB_STDIO (  Do the stdio thing, splat = CON:Filename )
  556.  
  557. 1 0 << constant PRF_SAVEIO
  558. 1 1 << constant PRF_CLOSESPLAT
  559. 1 2 << constant PRF_NOCLI
  560. 1 3 << constant PRF_INTERACTIVE
  561. 1 4 << constant PRF_CODE
  562. 1 5 << constant PRF_STDIO
  563.  
  564. (  Error returns from SyncRun[] and ASyncRun[] )
  565. -1  constant PR_NOFILE (  Could not LoadSeg[] the file )
  566. -2  constant PR_NOMEM (  No memory for something )
  567. -3  constant PR_NOCLI (  Only SyncRun[] will fail if call not cli )
  568. -4  constant PR_NOSLOT (  No room in TaskArray )
  569. -5  constant PR_NOINPUT (  Could not open input file )
  570. -6  constant PR_NOOUTPUT (  Could not get output file )
  571. -7  constant PR_NOLOCK (  Could not get a lock )
  572. -8  constant PR_ARGERR (  Bad argument to ASyncRun[] )
  573. -9  constant PR_NOBCPL (  Bad program passed to ASyncRun[] )
  574. -10  constant PR_BADLIB (  Bad library version )
  575. -11  constant PR_NOSTDIO (  Couldn't get stdio handles )
  576.  
  577. (  Programs should return this as result2 if need a cli and don't have one. )
  578.  
  579. 400  constant ERROR_NOT_CLI (  Program/function neeeds to be cli )
  580.  
  581. ( ******************* Resident Program Support ****************************)
  582. ( )
  583. (  * This is the kind of node allocated for you when yhou AddResidentPrg[] a code)
  584. (  * segment.  They are stored as a single linked list with the root in)
  585. (  * ArpBase.  If you absolutely *must* wander through this list instead of)
  586. (  * using the supplied functions, then you must first obtain the semaphore)
  587. (  * which protects this list, and then release it afterwards.)
  588. (  * Do not use Forbid[] and Permit[] to gain exclusive access!)
  589. (  * Note that the supplied functions handle this locking protocol for you.)
  590. (  )
  591.  
  592. :STRUCT ResidentPrgNode
  593.     APTR  rpn_Next    (  next or NULL )
  594.     LONG  rpn_Usage    (  Number of current users )
  595.     LONG  rpn_CheckSum    (  Checksum of code )
  596.     LONG  rpn_Segment    (  Actual segment )
  597.        byte rpn_Name
  598. ;STRUCT 
  599.  
  600.  
  601. (  If your program starts with this structure, ASyncRun[] and SyncRun[] will)
  602. (  * override a users stack request with the value in rpt_StackSize.)
  603. (  * Furthermore, if you are actually attached to the resident list, a memory)
  604. (  * block of size rpt_DataSize will be allocated for you, and)
  605. (  * a pointer to this data passed to you in register A4.  You may use this)
  606. (  * block to clone the data segment of programs, thus resulting in one)
  607. (  * copy of text, but multiple copies of data/bss for each process)
  608. (  * invocation.  If you are resident, your program will start at)
  609. (  * rpt_Instruction, otherwise, it will be launched from the initial branch.)
  610. (  )
  611.  
  612. :STRUCT ResidentProgramTag
  613.     LONG rpt_NextSeg    (  Provided by DOS at LoadSeg time. )
  614.     SHORT rpt_BRA    (  Short branch to executable )
  615.     SHORT rpt_Magic    (  Resident majik value )
  616.     LONG rpt_StackSize    (  min stack for this process )
  617.     LONG rpt_DataSize    (  Data size to allocate if resident )
  618.     (      rpt_Instruction; /* Start here if resident )
  619. ;STRUCT 
  620. ( )
  621. (  * The form of the ARP allocated node in your tasks memlist when launched)
  622. (  * as a resident program. Note that the data portion of the node will only)
  623. (  * exist if you have specified a nonzero value for rpt_DataSize. Note also)
  624. (  * that this structure is READ ONLY, modify values in this at your own)
  625. (  * risk.  The stack stuff is for tracking, if you need actual addresses)
  626. (  * or stack size, check the normal places for it in your process/task struct.)
  627. (  )
  628. :STRUCT ProcessMemory
  629.     STRUCT Node    pm_Node
  630.     SHORT pm_Num        (  This is 1 if no data, two if data )
  631.         LONG pm_Stack
  632.     LONG pm_StackSize
  633.         LONG pm_Data
  634.     LONG pm_DataSize
  635. ;STRUCT 
  636.  
  637. (  To find the above on your memlist, search for the following name.)
  638. (  * We guarantee this will be the only arp.library allocated node on)
  639. (  * your memlist with this name, i.e. FindName[task->tcb_MemEntry, PMEM_NAME];)
  640. (  )
  641. \ %? #define PMEM_NAME    "ARP_MEM"
  642.  
  643. $ 4AFC  constant RESIDENT_MAGIC (  same as RTC_MATCHWORD [trapf] )
  644.  
  645. (  The initial branch destination and rpt_Instruction do not have to be the same.)
  646. (  * This allows different actions to be taken if you are diskloaded or)
  647. (  * resident. DataSize memory will be allocated only if you are resident,)
  648. (  * but StackSize will override all user stack requests.)
  649. (  )
  650.  
  651. ( ********************** String/Data structures ************************)
  652.  
  653. :STRUCT DateTime
  654.     STRUCT DateStamp dat_Stamp    (  DOS Datestamp )
  655.     BYTE dat_Format    (  controls appearance ot dat_StrDate )
  656.     BYTE dat_Flags    (  See BITDEF's below )
  657.     APTR dat_StrDay    (  day of the week string )
  658.     APTR dat_StrDate    (  date string )
  659.     APTR dat_StrTime    (  time string )
  660. ;STRUCT 
  661.  
  662. (  Size of buffer you need for each DateTime strings: )
  663. 10  constant LEN_DATSTRING
  664.  
  665. (  For dat_Flags )
  666.  
  667. 0  constant DTB_SUBST (  Substitute "Today" "Tomorrow" where appropriate )
  668. 1  constant DTB_FUTURE (  Day of the week is in future )
  669.  
  670. 1 0 << constant DTF_SUBST
  671. 1 1 << constant DTF_FUTURE
  672.  
  673. (  For dat_Format )
  674. 0  constant FORMAT_DOS (  dd-mmm-yy AmigaDOS's own, unique style )
  675. 1  constant FORMAT_INT (  yy-mm-dd International format )
  676. 2  constant FORMAT_USA (  mm-dd-yy The good'ol'USA.    )
  677. 3  constant FORMAT_CDN (  dd-mm-yy Our brothers and sisters to the north )
  678. FORMAT_CDN  constant FORMAT_MAX (  Larger than this? Defaults to AmigaDOS )
  679. .THEN
  680.  
  681.